<?php
/**
 * Created by PhpStorm.
 * User: HuangLuSen
 * Date: 2017/5/13
 * Time: 10:33
 */

namespace app\mobile\controller;

use app\admin\model\AuthRule;
use app\common\controller\Base;
use app\mobile\model\Users;
use think\Controller;

class Mobile extends Base
{
    public $auth_ids_list;
    /**
     *初始化手机版
     */
    public function _initialize()
    {
        parent::_initialize();
        //session不存在时，不允许直接访问
        if(defined('UID')) return ;
        define('UID',is_login());

        //用户被禁用时不能再登录手机端
        $user = Users::get(['id'=>UID]);
        if(!empty($user) && $user['status']!=1){
            $this->redirect(url('mobile/login/loginfaild'));
        }

        session('jump',$this->request->controller().'/'.$this->request->action());
        if(!empty($this->request->param('id') && empty($this->request->param('code')))){
            $url= $_SERVER["REQUEST_SCHEME"].'://'.$_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
            session('order_url',$url);
        }
        if(!UID)$this->redirect(url('mobile/login/login'));

//        //今日追踪
//        if($this->hasRole('yaoyuezhuanyuan')||$this->hasRole('yaoyuezhuguan')||$this->hasRole('yaoyuejingli')||$this->hasRole('zongjingli')) {
//            if ($this->hasRole('yaoyuezhuanyuan')) {
//                $user = session('admin_user');
//                $map['yykf'] = $user['adminid'];
//            }
//            $start = strtotime(date('Y-m-d 00:00:00'));
//            $end = time();
//            $map['zztime'] = ['between time', [$start, $end]];
//            $map['ywstate'] = ['not in',[3,5,6]];
//            $map['status'] = 1;
//            $select = Db::name('order')->where($map)->count();
//            $this->assign('count_se',$select);
//        }
        /*获取提醒数据*/
        $this->gettixing();


        $auth=new AuthRule;
        $id_curr=$auth->get_url_id();//获取当前菜单的id
        if(!$auth->check_auth($id_curr)) $this->error('权限受限',url('mobile/index/index'));
        $this->auth_ids_list = $auth->mobilecheck();
    }
}